<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{padding: 0;margin: 0;}
        .adBox{
            width: 300px;
            height: 400px;
            background-color: #6ff;
            position: fixed;
            right: 5px;
            bottom: 5px;
            display: none;

        }
        .title{
            position: relative;
            font-size: 14px;
        }
        .title .tips{
            text-indent: 5px;
        }
        .title .close{
            position: absolute;
            right: 0;
            top: 0;
            padding: 0 4px;
            background-color: #f00;
        }
        .body img{
            width: 100%;
        }
    </style>
</head>
<body>
    <div class="adBox">
        <div class="title">
            <div class="tips">距离广告关闭还有10秒</div>
            <div class="close">x</div>
        </div>
        <div class="body">
            <a href="">
                <img src="https://img20.360buyimg.com/babel/s580x740_jfs/t1/169223/11/9002/236742/603f38feEa4a8d83e/4ace79eafcac855c.jpg!cc_290x370.webp" alt="">
            </a>
        </div>
    </div>
</body>
<script>
    // 小广告
    // (1)  延迟5秒 显示小广告
    // (2)  小广告显示之后 倒计时10秒   => 关闭
    // (3)  重复(1) (2) 操作


    var adBox = document.getElementsByClassName("adBox")[0];
    var tips = document.getElementsByClassName("tips")[0];
    setTimeout(function(){

        adBox.style.display = "block";
        var num = 10;
        var timer = setInterval(function(){
            num--;
            tips.innerText = `距离广告关闭还有${num}秒`;
            
            if(num == 0){
                clearInterval(timer);
                adBox.style.display = "none";
            }

        },1000);

    },000);



</script>
</html>